﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Text;
using DP.Web.UI;
using DP.Common;

namespace CRM.Web.Test
{
    public partial class testUserControl : System.Web.UI.UserControl
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StringBuilder sb = new StringBuilder();
                //保证验证函数的执行 
                sb.Append("if (typeof(Page_ClientValidate) == 'function') { if (Page_ClientValidate() == false) { return false; }};");
                //点击提交按钮后设置Button的disable属性防止用户再次点击,注意这里的this是JavaScript代码
                sb.Append("this.disabled  = true;");
                //用__doPostBack来提交，保证按钮的服务器端click事件执行 
                sb.Append(this.Page.ClientScript.GetPostBackEventReference(this.btnTest, ""));
                sb.Append(";");
                //SetUIStyle()是JavaScript函数,点击提交按钮后执行,如可以显示动画效果提示后台处理进度
                //注意SetUIStyle()定义在aspx页面中
                //sb.Append("SetUIStyle();");
                //给提交按钮增加OnClick属性
                this.btnTest.Attributes.Add("onclick", sb.ToString());
            //    btnTest.OnClientClick = "this.disabled=true;this.form.submit();";
            //    btnTest.UseSubmitBehavior = false;
                //txtTest.Text = DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss");
            }
        }


        protected void btnTest_Click(object sender, EventArgs e)
        {

            PageHelper.Open("http://www.163.com", "163");
            //System.Threading.Thread.Sleep(10000);
            //lblTest.Text = DateTime.Now.ToString("yyyy-MM-dd HH:MM:ss");

            //System.Threading.Thread SyncData = new Thread(new ParameterizedThreadStart(NewMethod));
            //SyncData.Start(null);
            //NewMethod(DateTime.Now);
        }

        private void NewMethod(object obj)
        {
            DateTime dateTime = DateTime.Now;
            System.Threading.Thread.Sleep(10000);
            LogHelper.WriteLog("btnTest", dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            
        }



    }
}